"""czllblog URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
import os

import xadmin
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls.static import static
from django.urls import path, include
from UserProfile import profile,info
from System import views
from Blog import blog
from czllblog import settings
from Files.views import uploadImg
from News import news
from Resources import resources

urlpatterns = [
    path('admin/', xadmin.site.urls),
    url(r'^$', xadmin.site.urls),
    url(r'^register/$', profile.Register.as_view()),
    url(r'^login/$', profile.Login.as_view()),
    url(r'^sendemail/$', profile.sendEmail.as_view()),
    url(r'^email_active/(.+)/$', profile.active),
    #系统
    url(r'^api/nav/$',views.Nav.as_view()),
    url(r'^api/carousel/$', views.Carousel.as_view()),
    ##工具
    #验证码
    path('captcha/', include('captcha.urls')),
    path('refresh_captcha/', profile.refreshCaptcha),
    #编辑器
    url(r'^ueditor/', include('DjangoUeditor.urls')),

    #个人
    url(r'^profile/info/$', info.UserInfo.as_view()),
    url(r'^profile/blog/$', info.Bloginfo.as_view()),
    url(r'^profile/collections/$', info.Collections.as_view()),

    #博客
    url(r'^api/blog/type/$', blog.Type.as_view()),
    url(r'^api/blog/put/$', blog.BlogPut.as_view()),
    url(r'^api/blog/list/$', blog.BlogList.as_view()),
    url(r'^api/blog/hot/$', blog.HotBlog.as_view()),
    url(r'^api/blog/good/$', blog.Goods.as_view()),
    url(r'^api/blog/comment/$', blog.Commtent.as_view()),
    url(r'^api/blog/collection/$', blog.Collection.as_view()),
    url(r'^api/blog/is_operation/$', blog.is_operation.as_view()),

    #新闻
    url(r'^api/news/type/$', news.Type.as_view()),
    url(r'^api/news/list/$', news.NewsList.as_view()),
    url(r'^api/news/hot/$', news.HotNews.as_view()),
    url(r'^api/news/good/$', news.Goods.as_view()),
    url(r'^api/news/comment/$', news.Commtent.as_view()),
    url(r'^api/news/is_operation/$', news.is_operation.as_view()),

    #资源
    url(r'^api/resources/type/$', resources.Type.as_view()),
    url(r'^api/resources/list/$', resources.ResourcesList.as_view()),
    url(r'^api/resources/hot/$', resources.HotResources.as_view()),
    url(r'^api/resources/good/$', resources.Goods.as_view()),
    url(r'^api/resources/comment/$', resources.Commtent.as_view()),
    url(r'^api/resources/is_operation/$', resources.is_operation.as_view()),

    #工具类
    #上传图片
    url(r'^util/uploadImg/', uploadImg),

]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# if settings.DEBUG:
#     media_root = os.path.join(settings.BASE_DIR, settings.MEDIA_ROOT)
#     urlpatterns += static(settings.MEDIA_URL, document_root=media_root)

